package 
{
	import flash.display.Scene;
	import net.flashpunk.Engine;
	import net.flashpunk.FP;
	import net.flashpunk.graphics.Text;
	import net.flashpunk.utils.Data;
	import net.flashpunk.utils.Key;
	
	/**
	 * ...
	 * @author Felix Fleiß, Martina Rasch
	 */
	
	public class Main extends Engine 
	{
		public var screen_width:int;
		public var screen_height:int;
		private var loaded:Boolean = false;
		private var source:String = "game.cfg";
		public function Main() 
		{
			writeCFG();
			Data.load("game.cfg");
			
			screen_width = Data.readInt("screen_width");
			screen_height = Data.readInt("screen_height");
			
			super(screen_width, screen_height);
			//FP.console.enable();
			//FP.watch("width", "height", "color");
			//FP.console.toggleKey = Key.ENTER;
			//Constructor, width, height, framerate, constant framerate
			//Level declaration
			//FP.world = new Level1();
			FP.world = new Menu(screen_width, screen_height);
			
			
		}
		override public function update():void 
		{
			super.update();
		}
		/**
		 * function to write cfg
		 */
		private function writeCFG():void {
			Data.writeString("version", "1");
			
			Data.writeInt("screen_width", 800);
			Data.writeInt("screen_height", 600);
			
			Data.writeString("player_speed", "200.0");//Number type must be saved as string
			Data.writeInt("player_height", 50);
			Data.writeInt("player_width", 80);
			Data.writeString("player_horizontal_speed", "0.0");//Number type must be saved as string
			Data.writeString("player_horizontal_acceleration", "1.0");//Number type must be saved as string
			Data.writeString("player_horizontal_brake", "0.1");//Number type must be saved as string
			Data.writeString("player_horizontal_brake_obstacle_punishment", "10.0");//Number type must be saved as string
			Data.writeString("player_horizontal_max_speed", "30.0");//Number type must be saved as string
			
			
			Data.writeString("obstacle_interval", "1.0");//Number type must be saved as string
			Data.writeString("obstacle_min_speed", "100.0");//Number type must be saved as string
			Data.writeString("obstacle_max_speed", "100.0");//Number type must be saved as string
			Data.writeString("bonustime_interval", "4.0");//Number type must be saved as string
			Data.writeString("bonustime_min_speed", "100.0");//Number type must be saved as string
			Data.writeString("bonustime_max_speed", "100.0");//Number type must be saved as string
			
			Data.writeString("singing_tolerance", "0.15");
			Data.writeString("player_bonustime", "3.0");//Number type must be saved as string
			
			Data.writeInt("time_to_play", 60);
			
			
			 //to reset
			/*Data.writeInt("score1", 0);
			Data.writeInt("score2", 0);
			Data.writeInt("score3", 0);
			Data.writeInt("score4", 0);
			Data.writeInt("score5", 0);
			
			Data.writeString("player1", "Player");
			Data.writeString("player2", "Player");
			Data.writeString("player3", "Player");
			Data.writeString("player4", "Player");
			Data.writeString("player5", "Player");*/
			
			//insert configuration data to write here
			Data.save("game.cfg");
		}
		
	}
	
}